package com.example.dryclean_admin.common;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.Data;

@Data
public class Result {
    private int code;//200或400
    private String msg;//成功/失败
    private Long total;//总记录数
    private Object data;//数据
    public static Result result(int code,String msg,Long total,Object data){
        Result res = new Result();
        res.setCode(code);
        res.setMsg(msg);
        res.setTotal(total);
        res.setData(data);
        return res;
    }
    public static Result fail(){
        return result(400,"fail",0L,null);
    }
    public static Result fail(String msg){
        return result(400,msg,0L,null);
    }
    public static Result success(){
        return result(200,"success",0L,null);
    }
    public static Result success(Object data){
        return result(200,"success",0L,data);
    }
    public static Result success(Object data,Long total){
        return result(200,"success",total,data);
    }
}
